<?php
include "../../../lib/list.php";
if($_GET['date'])$date			=	$_GET['date'];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-us">
<head>
<link rel="stylesheet" href="../../../css/print.css" type="text/css"></link>
<script language="javascript">
window.onload = function ()
{
	print();
}
</script>
</head>
<body style="padding:10px;margin:10px;">
        <table width="650"  border="0" height="491" cellpadding="0" cellspacing="0">
                                <tr> 
                                    <td valign="top">
                    <h1 class='rpt_title' style='font-size: 20px; height:25px;'>재&nbsp;고&nbsp;조&nbsp;정&nbsp;전&nbsp;표</h1>
             <!-- TopSql 시작 -->
                    <table border="0" cellpadding="0" cellspacing="0" width="650px">
                        <tr>
                           <td style="width:300px; vertical-align:top;">
                                <table class="p_rptT">
                                    <col width="100px" />
                                    <col />
                                    <tr>
						<?
						$query = "SELECT * FROM uatp_prdreview WHERE g_no = $g_no";
						$result = DBquery($query);
						
						$s_qry = "SELECT * FROM uatp_prdreview WHERE g_no = $g_no LIMIT 0,1";
						$shop = DBarray($s_qry); 
			
						$sql = "select * from uatp_shopinfo where no = ".$shop['out_s_no'];
						$name=DBarray($sql);
						$out_s_name=$name['name'];
						$sql = "select * from uatp_shopinfo where no = ".$shop['in_s_no'];
						$name=DBarray($sql);
						$in_s_name=$name['name'];
						$sql = "select * from uatp_staff where no = ".$shop['out_staff_no'];
						$name=DBarray($sql);
						$out_staff_name = $name['name'];
						$sql = "select * from uatp_staff where no = ".$shop['in_staff_no'];
						$name=DBarray($sql);
						$in_staff_name = $name['name'];
						$sql = "select * from uatp_prdgroup where no = ".$g_no;
						$group=DBarray($sql);
						
						?>
                                        <th style='height:15px'>전표번호</th>
                                        <td><?=date('Ymd',strtotime($group['date']))?>-<?=$group['no']?></td>
                                    </tr>
                                    <tr> 
                                        <th style='height:15px'>DATE</th>
                                        <td><?=date('Y/m/d',strtotime($group['date']))?></td>
                                    </tr>
                                </table>
                               
                                
                            </td>
                            <td rowspan="2">&nbsp;</td>
                            <td style="width:340px">
                                <table class="p_rptT">
                                    <col width="100px" />
                                    <col />
                                    <tr>
                                        <th style='height:15px'>보낸 점포명</th>
                                        <td><?=$out_s_name?></td>
                                    </tr>
                                    <tr>
                                        <th style='height:15px'>보낸 담당자</th>
                                        <td><?=$out_staff_name?></td>
                                    </tr>
                                </table>
                                
                                <table class="p_rptT">
                                    <col width="100px" />
                                    <col />
                                    <tr>
                                        <th style='height:15px'>받은 점포명</th>
                                        <td><?=$in_s_name?></td>
                                    </tr>
                                    <tr>
                                        <th style='height:15px'>받은 담당자</th>
                                        <td><?=$in_staff_name?></td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                    </table>
                    
                    
                    <!-- TopSql 끝 -->
        
                    <!-- 구매리스트 시작 -->
                    <table class="p_rptC" width="650" >                    
                            <col width="8%" />                            
                            <col width="" />                            
                            <col width="43%" />
                            <col width="9%" />                           
                            <col width="23%" />
                            <thead>
                        <tr>
                                        <th style="height:23px">순번</th>   
                                        <th style="height:23px">품목</th>   
                                        <th style="height:23px">품명 및 규격 </th>   
                                        <th style="height:23px">수량</th>   
                                        <th style="height:23px">적요</th>   
                        </tr>
                           <?php 
                    $bunho = 0;
					$query = "SELECT * FROM uatp_prdreview WHERE g_no = $g_no";
					$result = DBquery($query);
					while($list = mysql_fetch_array($result)){
						$bunho++;
					$qry = "SELECT * FROM uatp_product WHERE no = $list[p_no]";
					$product = DBarray($qry);
						$total_price += $list['price'];
						$total_count += $list['count'];
					if($list['unit']=='1'){
						$minus = '-';
					}
					?>
                        <tr height="22px;" >
                        <td style="text-align:center;font-size:11px; width:8%;"><?=$bunho?>&nbsp;</td>
                        <td style="text-align:left;font-size:11px; width:17%;">&nbsp;<?=$product['barcode']?>&nbsp;</td>
                        <td style="text-align:left;font-size:11px; width:43%;">&nbsp;<?=$product['productname']?>&nbsp;</td>
                        <td style="text-align:right;font-size:11px; width:9%;"><?=$minus?><?=$list['count']?>&nbsp;</td>
                        <td style="text-align:left;font-size:11px; width:23%;">&nbsp;</td>
                        </tr>
                    <?php
					} ?>
                        </thead>
                        <tbody>
                        </tbody>
                    </table>
                    <!-- 구매리스트 끝 -->
                
                    
                    <!-- 각페이지통계 시작(수량, 인수) -->
                    <table class="p_rptB">
                        <col width="100px" />
                        <col />
                        <col width="100px" />
                        <col width="150px" />
                        <tr>
                            <th style='height:13px'>수량</th>
                            <td class="right"><?=$minus?><?=$total_count?>&nbsp;</td>
                            <th style='height:13px'>인수</th>
                            <td class="right">인</td>
                        </tr>
                    </table>
                    <!-- 각페이지통계 끝 -->
                    <!-- 추가입력사항 시작 -->
                    <table class="p_rptB2"  style="margin:3px 0 0 0;">
                        <col width="15%" />
                        <col width="35%" />
                        <col width="15%" />
                        <col width="35%" />
                        
                    </table>            
                   </td>
                   </tr>
                   </table>         
</body>
</html>